package poker;

/**
 * This class represents a poker card.
 * @author guglielmo90
 */
public class Card implements Comparable{

    /**
     *
     * @param c
     * @return
     */
    @Override
    public int compareTo(Object d) {
        
        Card c = (Card)d;
        
        if(this.value == c.value)
            
            return 0;
        
        if(this.value == 1)
            
            return 1;
        
        if(c.value == 1)
            
            return -1;
        
        if(this.value > c.value)
            
            return 1;
        
        return -1;
        
    }
    
    private enum Suits {s, h, d, c};
    
    private int value;
    private Suits suit;
    
    public Card(){
    
        this.value = 0;
        this.suit = Suits.s;
    
    }
    
    public Card(int value, int suit){
    
        this.value = value;
        this.suit = getSuit(suit);
        
    }
    
    public int cardSuit(){
    
        return suit.ordinal();
    
    }
    
    public Suits getSuit(int n){
    
        switch(n){
        
            case 0 : 
                
                return Suits.s;
            
            case 1 :
                
                return Suits.h;
                
            case 2 :
                
                return Suits.d;
                
            case 3 :
                
                return Suits.c;
                
            default :
                
                return null;
        
        } 
    
    }
    
    public int getValue(){
    
        return this.value;
    
    }
    
    @Override
    public String toString(){
    
        String figure = Integer.toString(value);
        
        if(value == 1)
            
            figure = "A";
                    
        else if (value == 11)
            
            figure = "J";
            
            else if (value == 12)
                
                figure = "Q";
        
            else if (value == 13)
                
                figure = "K";
        
        return (figure + "" + suit);
    
    }
    
}

